import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import { settingRoutes } from "./modules/settings";
import { operateRoutes } from "./modules/operate";

export const Layout = () => import("@/layout/index.vue");

export const constantRoutes: RouteRecordRaw[] = [
  ...settingRoutes,
  ...operateRoutes,

  {
    path: "/global",
    name: "Global",
    component: Layout,
    redirect: "/global/defaultTemplate",
    meta: { title: "全局管理", icon: "ele-Menu" },
    children: [
      {
        path: "returnTemplate",
        name: "ReturnTemplate",
        component: () =>
          import("@/views/globalManage/returnTemplate/index.vue"),
        meta: { title: "回传模板", icon: "ele-HelpFilled" },
      },
      {
        path: "rechargeTemplate",
        name: "RechargeTemplate",
        component: () =>
          import("@/views/globalManage/rechargeTemplateLibrary/index.vue"),
        meta: { title: "充值模板库", icon: "ele-HomeFilled" },
      },
      {
        path: "appletRoute",
        name: "AppletRoute",
        component: () => import("@/views/globalManage/appletRoute/index.vue"),
        meta: { title: "小程序路径", icon: "ele-TrendCharts" },
      },
      {
        path: "appletManage",
        name: "AppletManage",
        component: () => import("@/views/globalManage/appletManage/index.vue"),
        meta: { title: "小程序管理", icon: "ele-FolderOpened" },
      },
      {
        path: "defaultTemplate",
        name: "DefaultTemplate",
        component: () =>
          import("@/views/globalManage/defaultRechargeTemplate/index.vue"),
        meta: { title: "默认充值模板", icon: "ele-Coin" },
      },
    ],
  },
  {
    path: "/episode",
    name: "Episode",
    component: Layout,
    redirect: "/episode/list",
    children: [
      {
        path: "list",
        name: "EpisodeList",
        component: () => import("@/views/episodeList/index.vue"),
        meta: { title: "剧集列表", icon: "ele-Film" },
      },
    ],
  },
  {
    path: "/promotion",
    name: "Promotion",
    component: Layout,
    redirect: "/promotion/list",
    children: [
      {
        path: "list",
        name: "PromotionLink",
        component: () => import("@/views/promotionLink/index.vue"),
        meta: { title: "推广链接", icon: "ele-Promotion" },
      },
    ],
  },
  {
    path: "/chart",
    name: "Chart",
    component: Layout,
    redirect: "/chart/orderList",
    meta: { title: "数据报表", icon: "ele-Histogram" },
    children: [
      {
        path: "orderList",
        name: "OrderList",
        component: () => import("@/views/chart/order/index.vue"),
        meta: { title: "订单列表", icon: "ele-Document" },
      },
      {
        path: "promotionList",
        name: "PromotionList",
        component: () => import("@/views/chart/promotion/index.vue"),
        meta: { title: "数据推广", icon: "ele-PieChart" },
      },
      {
        path: "operaReportList",
        name: "OperaReportList",
        component: () => import("@/views/chart/operaReport/index.vue"),
        meta: { title: "看剧统计", icon: "ele-Tickets" },
      },
      {
        path: "statisticsList",
        name: "StatisticsList",
        component: () => import("@/views/chart/statistics/index.vue"),
        meta: { title: "分成统计", icon: "ele-DocumentRemove" },
      },
      {
        path: "summaryList",
        name: "SummaryList",
        component: () => import("@/views/chart/summary/index.vue"),
        meta: { title: "数据汇总", icon: "ele-DataAnalysis" },
      },
    ],
  },
  {
    path: "/userManage",
    name: "UserManage",
    component: Layout,
    redirect: "/userManage/userList",
    // meta: { title: "用户管理", icon: "ele-Histogram" },
    children: [
      {
        path: "userList",
        name: "UserList",
        component: () => import("@/views/userManage/index.vue"),
        meta: { title: "用户管理", icon: "ele-UserFilled" },
      },
    ],
  },
  {
    path: "/echoRecord",
    name: "EchoRecord",
    component: Layout,
    // meta: { title: "用户管理", icon: "ele-Histogram" },
    children: [
      {
        path: "list",
        name: "EchoRecordList",
        component: () => import("@/views/echoRecord/index.vue"),
        meta: { title: "回传记录", icon: "ele-RefreshLeft" },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

export default router;
